package com.niiwoo.civet.trade.service.local.loan;

import com.niiwoo.civet.trade.dao.entity.*;
import com.niiwoo.civet.trade.dao.mapper.*;
import com.niiwoo.civet.trade.enums.ProjectTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: wuke
 * @Description:
 * @Date: Created in 11:48 2018/4/16
 */
@Slf4j
@Service
public class LoanConfigService {
    @Autowired
    private ProjectRateConfigMapperExt projectRateConfigMapper;
    @Autowired
    private RateConfigPercentMapperExt rateConfigPercentMapper;
    @Autowired
    private LoanBusinessConfigMapperExt loanBusinessConfigMapper;
    @Autowired
    private LoanBusinessInfoMapperExt loanBusinessInfoMapper;
    @Autowired
    private LoanCityConfigMapperExt loanCityConfigMapper;
    @Autowired
    private LoanQuantityConfigMapperExt loanQuantityConfigMapperExt;
    /**
     * 根据费率配置枚举类型获取借款费率配置列表
     * @param projectTypeEnum
     * @return
     */
    public List<ProjectRateConfig> selectRateConfigListByTypeEnum(ProjectTypeEnum projectTypeEnum){
        return projectRateConfigMapper.selectRateConfigListByProjectTypeEnum(projectTypeEnum);
    }

    public ProjectRateConfig selectRateConfigByDeadlineTypeEnum(Integer deadline, ProjectTypeEnum projectTypeEnum){
        return projectRateConfigMapper.selectRateConfigByDeadlineTypeEnum(deadline, projectTypeEnum);
    }

    public LoanBusinessConfig selectBusinessConfig(ProjectTypeEnum projectTypeEnum){
        return loanBusinessConfigMapper.selectByProductType(projectTypeEnum);
    }

    public LoanBusinessInfo selectBusinessInfo(ProjectTypeEnum projectTypeEnum){
        return loanBusinessInfoMapper.selectByProjectTypeEnum(projectTypeEnum);
    }

    public LoanCityConfig selectCityConfig(ProjectTypeEnum projectTypeEnum){
        return loanCityConfigMapper.selectByProjectTypeEnum(projectTypeEnum);
    }

    public LoanQuantityConfig selectLoanQuantityConfig(Byte projectType, Integer deadline){
        return loanQuantityConfigMapperExt.selectLoanQuantityConfig(projectType, deadline);
    }

    public List<RateConfigPercent> queryConfigPercentByRateConfigId(Long rateConfigId){
        return rateConfigPercentMapper.queryConfigPercentByRateConfigId(rateConfigId);
    }
}
